/*
*┌─────────────────────────────────┐
*│　描   述：
*│　类   名：CreateItem
*│　创  建  人：DD
*│　Copyright(C) 2020 by DD
*└─────────────────────────────────┘
*┌─────────────────────────────────┐
*│　修  改  人：
*│　修改方向：
*└─────────────────────────────────┘
*/
using UnityEngine;

namespace DD
{
    public class CreateItem : MonoBehaviour
    {
        #region 字段

        [SerializeField] private Transform[] m_parent;
        [SerializeField] private Transform BoomParent;
        [SerializeField] private Transform ForceParent;

        [SerializeField] private Transform SuperDIePlanelParent;


        [SerializeField] private GameObject m_item;
        [SerializeField] private GameObject m_item_Boom;
        [SerializeField] private GameObject m_item_Force;
        [SerializeField] private GameObject m_UserpDiePlanel;
        #endregion

        #region 内置函数
        private void Start( )
        {
            CreateItems ();

            //获得随机Item
            if ( ScoreManager.Instance._scoreValue >= 50 )//TODO
            {
                int Randoms =  Random.Range ( 0 , 100 );

                if ( Randoms <= 10 )
                {
                    //冲刺
                    CreateForceItem ();
                }
                else if ( Randoms <= 25 )
                {
                    //爆炸
                    CreateBoomItem ();
                }

            }

            if ( ScoreManager.Instance._scoreValue >= 100 )//TODO
            {
                if ( Random.Range ( 0 , 100f ) <= 40 )
                {
                    CreateSuperDidPlanel ();
                }
            }

        }
        #endregion

        #region 私有函数
        private void CreateItems( )
        {
            for ( int i = 0 ; i < Random.Range ( 1 , 4 ) ; i++ )
            {
                Instantiate ( m_item , m_parent[i].position , m_parent[i].rotation , m_parent[i] );
            }
        }

        private void CreateBoomItem( )
        {
            Instantiate ( m_item_Boom , BoomParent.position , BoomParent.rotation , BoomParent );
        }

        private void CreateForceItem( )
        {
            Instantiate ( m_item_Force , ForceParent.position , ForceParent.rotation , ForceParent );
        }
        private void CreateSuperDidPlanel( )
        {
            Instantiate ( m_UserpDiePlanel , SuperDIePlanelParent.position , SuperDIePlanelParent.rotation , SuperDIePlanelParent );
        }



        #endregion

        #region 共有函数
        #endregion
    }
}